import { CoolController, BaseController,CoolUrlTag,TagTypes  } from '@cool-midway/core';
import { Inject} from '@midwayjs/decorator';
import { Body, Get, Post} from '@midwayjs/core';
import { BroadcastRecipeEntity } from '../../entity/recipe';
import { UserInfoEntity } from '../../../user/entity/info';
import { BroadcastRecipeService } from '../../service/recipe';

/**
 * 广播-参考方
 */
@CoolUrlTag({
  key: TagTypes.IGNORE_TOKEN,
  value: ['info','list','page','getRecipeOrParent'],
})
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: BroadcastRecipeEntity,
  service:BroadcastRecipeService,
  // 分页查询配置
  pageQueryOp: {
    // 让title字段支持模糊查询
    keyWordLikeFields: ['name',"numeral","description",'keywords'],
  },
})
export class AppBroadcastRecipesController extends BaseController {
  // getRecipeOrParent
  @Inject()
  BroadcastRecipeService: BroadcastRecipeService;

  @Post('/getRecipeOrParent', { summary: '获取id的数据和子集' })
  async getRecipeOrParent(@Body('id') id: string) {
    return this.ok(
      await this.BroadcastRecipeService.getRecipeOrParent(id)
    );
  }
}
